package org.xwalk.core.internal;


import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

public class XWalkNativeExtensionLoaderBridge extends XWalkNativeExtensionLoaderInternal {
    private XWalkCoreBridge coreBridge;
    private Object wrapper;

    public Object getWrapper() {
        return wrapper;
    }



    public XWalkNativeExtensionLoaderBridge(Object wrapper) {
        this.wrapper = wrapper;
        reflectionInit();
    }

    @Override
    public void registerNativeExtensionsInPath(String path) {
        if (registerNativeExtensionsInPathStringMethod == null || registerNativeExtensionsInPathStringMethod.isNull()) {
            registerNativeExtensionsInPathSuper(path);
        } else {
            registerNativeExtensionsInPathStringMethod.invoke(path);
        }
    }

    public void registerNativeExtensionsInPathSuper(String path) {
        super.registerNativeExtensionsInPath(path);
    }

    private ReflectMethod registerNativeExtensionsInPathStringMethod = new ReflectMethod(null, "registerNativeExtensionsInPath");


    void reflectionInit() {
        coreBridge = XWalkCoreBridge.getInstance();
        if (coreBridge == null) return;

        registerNativeExtensionsInPathStringMethod.init(wrapper, null,
                "registerNativeExtensionsInPath", String.class);
    }
}
